import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';

class QRCodeScannerController extends GetxController {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  RxString qrCodeResult = ''.obs;
  QRViewController? controller;

  void onQRViewCreated(QRViewController qrController) {
    controller ??= qrController;
    qrController.scannedDataStream.listen((scanData) {
      qrCodeResult.value = scanData.code ?? "";
      update();
      // qrController.pauseCamera();
    });
    update();
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }
}
